package com.yinhai.springmvc.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.yinhai.springmvc.po.Emp;
import com.yinhai.springmvc.po.EmpQueryVo;
import com.yinhai.springmvc.service.EmpService;

@Controller
@RequestMapping("/empFind")
public class EmpFindAction {
	
	@Autowired
	private EmpService empService;
	
	
	@RequestMapping("/empFind")//可加.action也可以不加
	public ModelAndView empFind() throws Exception{
		
		EmpQueryVo vo = new EmpQueryVo();
		Emp emp = new Emp();
		emp.setJob("SALESMAN");
		vo.setEmp(emp);
		List empList = empService.findEmpList(vo);
		//返回ModelAndView
		ModelAndView modelAndView = new ModelAndView();
		//相当于request.setAttribute,在jsp页面取数据
		modelAndView.addObject("empList", empList);
				
		//指定视图
		modelAndView.setViewName("emps/empList");
				
				
		return modelAndView;
	} 
	
}
